<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="80">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="80">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话号码"
        width="150">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="150">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="200">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="currentPage"
      :page-size="pageSize"
      layout="prev, pager, next"
      :total="totals"
      @current-change="pageQuery(currentPage)"
    >

    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      currentPage : 1,
      pageSize:5,
      totals:20,
      tableData: []
    }
  },
  methods:{
    handleEdit(){

    },
    handleDelete(){

    },
    getStudents(){
      this.$http.post("/student/list",{"currentPage":this.currentPage,"pageSize":this.pageSize}).then(res=>{
        console.log(res);
        this.tableData = res.data.data;
        this.totals = res.data.totals;
      }).catch(res=>{

      })
    },
    pageQuery(currentPage){
      this.currentPage = currentPage;
      this.getStudents();
    }
  },
  mounted() {
    this.getStudents();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
